#include <iostream>
#include <vector>
#define int long long

using namespace std;

class Solution {
  public:
    int count(vector<int> &heights, int k) {
        int len = heights.size(), cnt = 0;
        auto max = [](int a, int b) { return (a > b) ? a : b; };
        for (int i = 0; i < len; i++)
            cnt += max(0, heights[i] - k);
        return cnt;
    }

    int TreeChop(vector<int> &heights, int target) {
        int len = heights.size(), right = 0, left = 0x7fffffff;
        int posAns, posCnt = -1;
        auto min = [](int a, int b) { return (a < b) ? a : b; };
        auto max = [](int a, int b) { return (a > b) ? a : b; };

        for (int i = 0; i < len; i++) {
            right = max(right, heights[i]);
            left = min(left, heights[i]);
        }

        while (left <= right) {
            int mid = (left + right) / 2;
            int cnt = count(heights, mid);

            if (cnt == target) {
                return mid;
            } else if (cnt >= target) {
                left = mid + 1;
                if (posCnt == -1) {
                    posCnt = cnt;
                    posAns = mid;
                } else {
                    if (posCnt > cnt) {
                        posCnt = cnt;
                        posAns = mid;
                    }
                }
            } else {
                right = mid - 1;
            }
        }
        return posAns;
    }
};
#undef int
int main() {
#define int long long
    int n, m;
    cin >> n >> m;
    vector<int> inp(n);
    for (int i = 0; i < n; i++)
        cin >> inp[i];
    Solution sol;
    cout << sol.TreeChop(inp, m);
}